using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for user_pc
/// </summary>
public class user_pc
{
    private int _id;

    public int Id
    {
        get { return _id; }
        set { _id = value; }
    }
    private string _name;

    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }
    private string _username;

    public string Username
    {
        get { return _username; }
        set { _username = value; }
    }
    private string _identify_card;

    public string Identify_card
    {
        get { return _identify_card; }
        set { _identify_card = value; }
    }
    private string _password;

    public string Password
    {
        get { return _password; }
        set { _password = value; }
    }
    private DateTime _birthday;

    public DateTime Birthday
    {
        get { return _birthday; }
        set { _birthday = value; }
    }
    private int _types_id;

    public int Types_id
    {
        get { return _types_id; }
        set { _types_id = value; }
    }
    private string _nick_yahoo;

    public string Nick_yahoo
    {
        get { return _nick_yahoo; }
        set { _nick_yahoo = value; }
    }
    private string _email;

    public string Email
    {
        get { return _email; }
        set { _email = value; }
    }
    private string _phone;

    public string Phone
    {
        get { return _phone; }
        set { _phone = value; }
    }
    private string _mobile_phone;

    public string Mobile_phone
    {
        get { return _mobile_phone; }
        set { _mobile_phone = value; }
    }
    private string _address;

    public string Address
    {
        get { return _address; }
        set { _address = value; }
    }
   private int _city_id;
    public int City_id
    {
        get { return _city_id; }
        set { _city_id = value; }
    }
   private int _country_id;
    public int Country_id
    {
        get { return _country_id; }
        set { _country_id = value; }
    }
   private int _activation;
    public int Activation
    {
        get { return _activation; }
        set { _activation = value; }
    }
   private DateTime _date_added;
    public DateTime Date_added
    {
        get { return _date_added; }
        set { _date_added = value; }
    }
   private DateTime _last_modified;
    public DateTime Last_modified
    {
        get { return _last_modified; }
        set { _last_modified = value; }
    }
    public user_pc()
	{
		   _id = 0;
           _name ="";
           _username = "";
           _identify_card = "";
           _password = "";
           _birthday = DateTime.Now;
           _types_id = 0;
           _nick_yahoo = "";
           _email = "";
           _phone = "";
           _mobile_phone = "";
           _address = "";
           _city_id = 0;
           _country_id = 0;
           _activation = 0;
           _date_added = DateTime.Now;
           _last_modified = DateTime.Now;
	}
    DBconnect DB = new DBconnect();
    public Boolean Login()
    {
        Functions fnc = new Functions();
        Boolean result = false;
        DB.Open();
        DataTable Tmp = new DataTable();
        string pass = fnc.Md5Encode(this.Password);
        Tmp = DB.GetDataTable("select ID,name,types_id from users where username='" + this.Username + "' and password='" + pass+ "'");
        if (Tmp.Rows.Count > 0)
        {
            result = true;

            this.Id = Convert.ToInt32(Tmp.Rows[0]["id"].ToString());
            this.Name = Tmp.Rows[0]["name"].ToString();
            this.Types_id = Convert.ToInt32(Tmp.Rows[0]["types_id"].ToString());
        }
        DB.Close();
        return result;
    }

}
